<?php
namespace Tbf\Bundle\PackageBundle\ClassGenerator;
use CG\Core\AbstractClassGenerator;
use Tbf\Component\FileSystem\FileSystemFunction;
use Tbf\Bundle\PackageBundle\Exception\PackageException;

class EntityGenerator extends AbstractClassGenerator
{
    public function generate(EntityDefine $cg)
    {
        return $this->generateCode($cg);
    }
    public function generateToFile(EntityDefine $cg)
    {
        $content = $this->generate($cg);
        $content = '<?php'."\n".$content;
        FileSystemFunction::putContent($cg->getFilePath(),$content);
    }

    /**
     * 这个函数调用是没有意义的,
     * 但是要继承AbstractClassGenerator 就要实现它...
     * Call EntityGenerator::generateClass is meaningless,
     * but has to implement it to extends AbstractClassGenerator
     */
    public function generateClass()
    {
        throw new PackageException('Call EntityGenerator::generateClass is meaningless');
    }
}
